package com.czkt.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czkt.entity.vo.BasDictAndCstCustomer;
import com.czkt.service.ConsRptService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class ConsRptController {
    @Resource
    ConsRptService consRptService;

    @RequestMapping("/consRpt/list")
    public String consRptShow(@RequestParam(defaultValue = "1") Integer pageIndex,
                              @RequestParam(defaultValue = "2") Integer pageSize,
                              Model model){
        IPage<BasDictAndCstCustomer> page = consRptService.selectBasDictByCustomer(pageIndex,pageSize);
        String[] consRptName = consRptService.selectBasDictByCustomer().stream()
                .map(BasDictAndCstCustomer::getDictItem)
                .toArray(String[]::new);
        String[] consRptNumber = consRptService.selectBasDictByCustomer().stream()
                .map(BasDictAndCstCustomer::getCustLevelLabel)
                .toArray(String[]::new);
        model.addAttribute("consRptName",consRptName);
        model.addAttribute("consRptNumber",consRptNumber);
        model.addAttribute("page",page);
        return "/consRpt/list";
    }
}
